package com.yonyougov.cruxtestcase.dto;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class BaseResponseDto {
    private Boolean success;
    private String errorCode;
    private String errorMsg;
    private Map<String, Object> data = new HashMap<>();

    public void clear() {
        this.data.clear();
        this.setSuccess(false);
        this.errorCode = null;
        this.setErrorMsg((String) null);
    }

    public void put(String key, Object object) {
        this.data.put(key, object);
    }

    @SuppressWarnings("unchecked")
    public <T> T get(String key) {
        return (T) this.data.getOrDefault(key, null);
    }

    public BaseResponseDto() {
    }

    public <T> void setData(String key, T Value) {
        this.data.put(key,Value);
    }
}
